<template>
  <el-form-item
    :label="labelName"
    :prop="isRequire ? 'name' : ''"
    :rules="rules"
    class="common-form-width"
  >
  <el-radio-group v-model="modelValue">
    <el-radio :label="0">否</el-radio>
    <el-radio :label="1">是</el-radio>
  </el-radio-group>
  </el-form-item>
</template>

<script lang="ts" setup>
const props = withDefaults(
  defineProps<{
    modelValue: string;
    labelName: string;
    isRequire: boolean;
  }>(),
  {
    modelValue: "",
    labelName: "",
    isRequire: false,
  }
);
const { labelName } = toRefs(props);
const emits = defineEmits(["update:model-value"]);
const modelValue = computed({
  set(newValue) {
    emits("update:model-value", newValue);
  },
  get() {
    return props.modelValue;
  },
});

const rules = [
  {
    required: true,
    message: `请输入${labelName.value}`,
    trigger: "blur",
  },
];
</script>

<style scoped lang="scss">
@use "@/components/goodsCenter/styles/common.scss";
</style>
